#ifndef __DOUBLELINKLIST_H_
#define __DOUBLELINKLIST_H_
#include <stddef.h>
//#include "dynamicArray.h"
class doubleLinkList{

    public:
    using elementType =void*;
    size_t Size();
    doubleLinkList();
    //拷贝构造 赋值运算符重载
    doubleLinkList(const doubleLinkList& d);
    doubleLinkList& operator=(const doubleLinkList& d);

    ~doubleLinkList();
    void insertTail(const elementType& element);
    void insertByIndex(size_t index,const elementType &element);
    
    //删除
    void removeByIndex(size_t index);
    void removeByElement(const elementType &element);

    //查找
    elementType* findByIndex(size_t index);
    //DARRAY::dynamicArray findByElement(const elementType &element);

    //修改
    void updateByIndex(size_t index,const elementType& element);
    void updateByElement(const elementType& oldValue,const elementType& newValue);

    //排序 快速
    void sort();
    void show();

    void setFunc(void (*Free)(void*),void (*print)(void*),bool (*compare)(void*,void*),bool (*cmpBig)(void*,void*)){
        this->Free=Free;
        this->print=print;
        this->compare=compare;
        this->cmpBig=cmpBig;
    }

    private:
    struct Node{
        Node(const elementType& value){
            this->value=value;
            next=prev=nullptr;
        }
        elementType value;
        Node *next;//前驱指针
        Node *prev;//后驱
    };
    Node *head;//头指针
    Node *tail;//尾指针
    size_t size;
    void fastSort(Node *start, Node *end);
    void (*Free)(void*);
    bool (*compare)(void*,void*);//比较大小的指针
    bool (*cmpBig)(void*,void*);
    void (*print)(void*);//打印数据的指针
};
#endif